﻿using UnityEngine;
using System.Collections;

public class Thero : TSprite {

	static Thero instance;
	
	public static Thero GetInstance()
	{
		return instance;
	}
	
	void Awake()
	{
		instance = this;
	}
	
	public override void Init ()
	{
		base.Init ();
		
		HeroSacle();
		ResetCollider();
	}
	
	/// <summary>
	/// 英雄图片进行缩放控制
	/// </summary>
	void HeroSacle()
	{
		if(ViewRect.GetInstance())
		{
			transform.localScale = ViewRect.GetInstance().HeroScaleV;
		}
	}
	
	/// <summary>
	/// 重新设置碰撞盒
	/// </summary>
	void ResetCollider()
	{
		if(transform.collider != null)
		{
			Destroy(transform.collider);
		}
		BoxCollider box = NGUITools.AddWidgetCollider(gameObject);
		box.size = new Vector3(Screen.width, Screen.height, 1) * 4;
	}
}
